﻿<UserControl x:Class="ViewDashboardPropertyGrid"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:local="clr-namespace:OMANE.Modules.Dashboarding"
             xmlns:system="clr-namespace:System;assembly=mscorlib" 
                >
    <!--xml:lang="fr-FR"-->
    <UserControl.Resources>
        <DataTemplate x:Key="PropertiesDataGridrowHeaderTemplate">
            <CheckBox IsThreeState="False" DataContext="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=DataContext}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=DataContext.Include, Mode=TwoWay}" Margin="5" />
        </DataTemplate>
    </UserControl.Resources>


        <Grid Margin="5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="150" />
            <ColumnDefinition Width="5" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True"  >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid MinHeight="35">
                        <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="16" FontWeight="Bold" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1"  />
        <DataGrid 
            IsSynchronizedWithCurrentItem="True" 
            Background="White" 
            SelectionMode="Single"
            SelectionUnit="FullRow" 
            CanUserDeleteRows="False"
            CanUserAddRows="False"  
            ItemsSource="{Binding Path=/Properties}"
            Name="PropertiesDataGrid" 
            AutoGenerateColumns="False" 
            Grid.Column="2"  >
          
            <DataGrid.CellStyle>
                <Style TargetType="DataGridCell" >
                    <Setter Property="IsEnabled"  Value="{Binding Include}"/>
                </Style>                
            </DataGrid.CellStyle>
            
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding DisplayName}" IsReadOnly="True" Width="SizeToCells"  >
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock" >
                            <Setter Property="Margin" Value="1,3,20,3" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTemplateColumn Width="200">
                    <DataGridTemplateColumn.CellTemplateSelector>
                        <local:PropertyGridCellTemplateSelector />
                    </DataGridTemplateColumn.CellTemplateSelector>
                    <DataGridTemplateColumn.CellEditingTemplateSelector>
                        <local:PropertyGridCellEditingTemplateSelector />
                    </DataGridTemplateColumn.CellEditingTemplateSelector>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="SizeToCells">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button 
                                Background="White" 
                                Focusable="False" 
                                BorderBrush="Black" 
                                BorderThickness="1" 
                                Height="10" 
                                Width="10" 
                                VerticalAlignment="Center" 
                                HorizontalAlignment="Center"
                                Click="EditPropertyButtonClick">

                                <Button.ContextMenu>
                                    <ContextMenu >
                                        <MenuItem Header="Initialiser" />
                                        <Separator />
                                        <MenuItem Header="Creer Ressource" />
                                        <MenuItem Header="Modifier Ressource" />
                                        <MenuItem Header="Appliquer Ressource" />
                                        <Separator />
                                        <MenuItem    DataContext="{Binding}" Header="Lier aux Donnees" Click="DataBindMenuItemClick" />
                                        <MenuItem Header="Lier a une Zone" />
                                    </ContextMenu>
                                </Button.ContextMenu>
                            </Button>

                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
